package com.symria.framework.dao.util;

import java.io.Serializable;
import java.util.Collection;

import com.symria.system.statement.mysql.StatementFactoryImpl;

public abstract class TemplateDao {
	public StatementFactoryImpl stmsFactory;
    public HibernateDao templateDao;

	public StatementFactoryImpl getStmsFactory() {
		return stmsFactory;
	}

	public void setStmsFactory(StatementFactoryImpl stmsFactory) {
		this.stmsFactory = stmsFactory;
	}

	public HibernateDao getTemplateDao() {
		return templateDao;
	}

	public void setTemplateDao(HibernateDao templateDao) {
		this.templateDao = templateDao;
	}
	
	public void saveObject(Object obj) {
		templateDao.createObject(obj);
	}
	public void saveOrUpdate(Object obj) {
		templateDao.saveOrUpdate(obj);
	}
	public void savebatchObject(Collection<Object> entities) {
		templateDao.saveObjects(entities);
	}

	/**删除数据*/
    public void deleteObject(Class clazz,Serializable id){
    	templateDao.deleteObject(clazz, id);
    }
	public void deleteObject(Object obj) {
		templateDao.deleteObject(obj);
	}
	public void deleteObjects(Collection entities) {
		templateDao.deleteObjects(entities);
	}
	public void deleteObject(Serializable id, Class clazz){
		templateDao.deleteObject(clazz, id);
	}
	/**更新数据*/
	public void updateObject(Object obj) {
		templateDao.updateObject(obj);
	}
    

	
    /**查询单个数据*/
	public <T> T getObject(Serializable id, Class <T> toType) {
		return templateDao.get(id, toType);
	}
	public <T> T loadObject(Serializable id, Class <T> toType){
		return templateDao.load(id, toType);
	}
	public Object loadObject(Class clazz, Serializable id) {
		return templateDao.loadObject(clazz, id);
	}
	public Object getObject(Class clazz, Serializable id) {
		return templateDao.getObject(clazz, id);
	}
}
